home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / port / resid.h < prev    next >
C/C++ Source or Header  |  1996-07-10  |  7KB  |  262 lines

  1. /* @0203    05/09/91    *//* delete pparm */
  2. /* @0206    06/09/91    *//* videobuf */
  3. /* @0207    06/09/91    *//* videobuf */
  4. /* @0209     07/09/91    *//* videobuf */
  5. /* @0215    14/09/91    *//* Bufvt & overlay */
  6. /* @0224    20/09/91    *//* BSS */
  7. /* k 0233    12/10/91    *//* Trn modules */
  8. /* k 0234       14/10/91        *//* OVL_TYPE */
  9. /* k 0246       22/10/91        *//* FP_OFF */
  10. /*#define DEBUG*/
  11. #include <ebss.h>
  12. #include <alloc.h>
  13. #if (OS_TYPE==0)
  14. #include <portparm.h>
  15. #define FP_OFF(fp)    ((unsigned)(fp))    /* @0246 */
  16. #define FP_SEG(fp)    ((unsigned)((unsigned long)(fp) >> 16))
  17. #define MK_FP(seg,ofs)    ((void far *) \
  18.                (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  19. #else
  20. #include <mortparm.h>
  21. #endif
  22. void initcolortable();
  23. void initcursor();
  24. #if (OS_TYPE == 0)        /* @0207 */
  25. #else                /* @0207 */
  26. extern char far *videobuf;        /* @0206 */
  27. #endif                /* @0207 */
  28. unsigned int igetcursor();
  29. resid ( ) {
  30. #if (OS_TYPE==0)
  31. #if !defined (DEBUG)
  32. unsigned x=getpsp(), y;
  33. void  * last;
  34. #endif
  35. #endif
  36. if (optflg & VT_OPT)        /* @0203 */
  37.   initcursor();
  38. if (optflg & EM_OPT)        /* @0203 */
  39. {
  40.  initcolortable();
  41.  initcolors ( );
  42. }
  43. #if (OS_TYPE==0)
  44.  bufvt2580.cursor_size=NOCURSOR;    /* @0215 */
  45.  bufvt2580.winleft=1;            /* @0215 */
  46.  bufvt2580.wintop=3;            /* @0215 */
  47.  bufvt2580.winright=80;        /* @0215 */
  48.  bufvt2580.winbottom=23;        /* @0215 */
  49.  bufvt2580.curx=1;            /* @0215 */
  50.  bufvt2580.cury=1;            /* @0215 */
  51.  #if !defined (DEBUG)   /* @0185 */
  52.   last= malloc (1);
  53.   y=FP_SEG (last);
  54.   y+=1;
  55. modsegment=x+16;                                /* OVERLAY */
  56. ovlsegment=FP_SEG (res_area);
  57. if (FP_OFF (res_area) != 0) ovlsegment++;
  58. newsegment=ovlsegment; /* one overlay area */   /* OVERLAY */
  59. {
  60.  int i,j; 
  61.  struct tran_ovl *TOVL=transit;
  62.  for (j=0;j<OVERNUM;j++) {
  63.    union ovl_text * OVLT;
  64.    OVLT= (union ovl_text *) TOVL->Func;
  65.    for (i=0;i<TOVL->number_of_func;i++) {
  66.             OVLT->i.f.fa.s+=ovlsegment;
  67.             OVLT++;
  68.             };
  69.    TOVL++;
  70.    }
  71. }
  72. ovl_area=MK_FP (ovlsegment,0);                  /* OVERLAY */
  73.   inst (x,y);
  74. }
  75.  #else
  76.     rdos=&rentdos;    /* @0209 */
  77.     router ( );
  78. }
  79.  #endif
  80. #endif
  81. void initcursor()    /* @0184 */
  82. /* Initializes the different cursor types */
  83. {
  84. #if (OS_TYPE==4)
  85. int selector,fd;
  86. char * device;
  87. int video;
  88. video=ioctl (0,CONS_CURRENT,0);        /* @0189 */
  89. switch(video) {
  90.  case VGA:
  91.     adaptMAP=MAPVGA;    /* @0184 */
  92.     adaptIO=VGAIO;
  93.     adaptMD=SW_VGA80x25;
  94.     device="/dev/vga";
  95.     nocursor=0x0100;
  96.     shortcursor=0x0A0C;
  97.     tallcursor = 0x090C;
  98.     break;    /* @0189 */
  99.  case PGA:
  100.     adaptMAP=MAPPGA;    /* @0184 */
  101.     adaptIO=PGAIO;
  102.     adaptMD=SW_ENHC80x25;
  103.     device="/dev/pga";
  104.     nocursor=0x0100;
  105.     shortcursor=0x0A0C;
  106.     tallcursor = 0x090C;
  107.     break;    /* @0189 */
  108.  case EGA:
  109.     adaptMAP=MAPEGA;    /* @0184 */
  110.     adaptIO=EGAIO;
  111.     adaptMD=SW_ENHC80x25;
  112.     device="/dev/ega";
  113.     nocursor=0x0100;
  114.     shortcursor=0x0A0C;
  115.     tallcursor = 0x090C;
  116.     break;
  117.  case CGA:
  118.     adaptMAP=MAPCGA;    /* @0184 */
  119.     adaptIO=CGAIO;
  120.     adaptMD=SW_C80x25;
  121.     device="/dev/color";
  122.     nocursor=0x0100;
  123.     shortcursor=0x0607;
  124.     tallcursor = 0x0507;
  125.     break;
  126.  case MONO:
  127.     adaptMAP=MAPMONO;    /* @0184 */
  128.     adaptIO=MCAIO;
  129.     adaptMD=SW_MCAMODE;
  130.     device="/dev/monochrome";
  131.     nocursor=0x0100;
  132.     shortcursor=0x0A0C;
  133.     tallcursor = 0x090C;
  134. }
  135.  ioctl (0,adaptMD,0);
  136.  fd=open(device,O_RDWR);
  137.  selector=ioctl(fd,adaptMAP,0);
  138. videobuf=(char far *)selector;        /* @0189 */
  139. /* videobuf=sotofar(selector,0);    */
  140. #endif
  141.  
  142. #if (OS_TYPE==3)
  143.   nocursor=0x0100;
  144. #endif
  145.  
  146.  
  147. #if (OS_TYPE==0)            /* @0215 */
  148.  if (!icheck_mode( )) /* MONO */    /* @0215 */
  149. #else                    /* @0215 */
  150.  if (!check_mode( )) /* MONO */    /* @0215 */
  151. #endif                    /* @0215 */
  152.  {
  153. #if (OS_TYPE!=4)
  154.   shortcursor=0x0A0C;
  155.   tallcursor = 0x090C;
  156.   videobuf=(char *)0xb0000000;        /* @0209 */
  157. #endif
  158.   vissegment=0xB000;
  159.   baseport=0x3B4;
  160.  }
  161.  else
  162.  {
  163. #if (OS_TYPE!=4)
  164.   shortcursor = 0x0607;
  165.   tallcursor = 0x0507;
  166.   videobuf=(char *)0xb8000000;        /* @0209 */
  167. #endif
  168.   vissegment=0xB800;
  169.   baseport=0x3D4;
  170.  }
  171.  
  172. #if ((OS_TYPE!=3)&&(OS_TYPE!=4))
  173.  oldcursor = igetcursor();        /* @0215 */
  174. #else
  175.  oldcursor = shortcursor;
  176. #endif
  177.  
  178. /* @0209 */
  179. } /* initcursor */
  180. void initcolortable()          /* @0184 */
  181. /* Sets up the color table */
  182. {
  183.   int color, fg, bg, fcolor, bcolor;
  184. #if (OS_TYPE==0)            /* @0215 */
  185.   if (icheck_mode ( ) )            /* @0215 */
  186. #else                    /* @0215 */
  187.   if (check_mode ( ) )            /* @0215 */
  188. #endif                    /* @0215 */
  189.   {
  190.     for (color = 0; color <= 255; color++)
  191.       colortable[color] = color;
  192.   }
  193.   else
  194.   {
  195.     for (fg = BLACK; fg <= WHITE; fg++)
  196.     {
  197.       if (fg == BLACK)
  198.         fcolor = BLACK;
  199.       else if (fg <= LIGHTGRAY)
  200.         fcolor = LIGHTGRAY;
  201.       else
  202.         fcolor = WHITE;
  203.       for (bg = BLACK; bg <= LIGHTGRAY; bg++)
  204.       {
  205.         if (bg == BLACK)
  206.           bcolor = BLACK;
  207.         else
  208.   {
  209.           if (fcolor == WHITE)
  210.             fcolor = BLACK;
  211.           bcolor = LIGHTGRAY;
  212.         }
  213.         colortable[fg + (bg << 4)] = fcolor + (bcolor << 4);
  214.       }
  215.     }
  216.     for (fg = 128; fg <= 255; fg++)
  217.       colortable[fg] = colortable[fg - 128] | 0x80;
  218.   }
  219. } /* initcolortable */
  220. initcolors ( ) {
  221.  ind_y=25;
  222.  enable_x1=8;
  223.  enable_x2=17;
  224.  insert_x=26;
  225.       mix=&screen[0].icon;
  226.       attrib[0]=BLACK*16+LIGHTGRAY;
  227.       attrib[1]=BLACK*16+LIGHTGRAY+BLINK;
  228.       attrib[2]=BLACK*16+LIGHTGRAY;
  229.       attrib[3]=BLACK*16+LIGHTGRAY+BLINK;
  230.       attrib[4]=BLACK*16+WHITE;
  231.       attrib[5]=BLACK*16+WHITE+BLINK;
  232.       attrib[6]=BLACK*16+BLACK;
  233.       attrib[7]=BLACK*16+BLACK;
  234.       attrib[8]=BLACK*16+GREEN;
  235.       attrib[9]=BLACK*16+GREEN+BLINK;
  236.       attrib[10]=BLACK*16+GREEN;
  237.       attrib[11]=BLACK*16+GREEN+BLINK;
  238.       attrib[12]=BLACK*16+LIGHTGREEN;
  239.       attrib[13]=BLACK*16+LIGHTGREEN+BLINK;
  240.       attrib[14]=BLACK*16+BLACK;
  241.       attrib[15]=BLACK*16+BLACK;
  242. }
  243. #if (OS_TYPE==0)        /* @0215 */
  244. int icheck_mode ( ) {        /* @0215 */
  245.  union REGS reg;
  246.             /* @0233 */
  247.  reg.h.ah = 15;
  248.  int86(0X10, ®, ®);
  249.  if (reg.h.al==7) return 0;
  250.  return 1;
  251.             }             /* @0215 */
  252. unsigned int igetcursor()    /* @0215 */
  253. /* Returns the shape of the current cursor */    /* @0215 */
  254. {                               /* @0215 */
  255.  union REGS reg;                /* @0215 */
  256.                                 /* @0215 */
  257.  reg.h.ah = 3;                  /* @0215 */
  258.  reg.h.bh = 0;                  /* @0215 */
  259.  int86(0X10, ®, ®);       /* @0215 */
  260.  return(reg.x.cx);              /* @0215 */
  261. }                /* @0215 */
  262. #endif                /* @0215 */